import * as ElementPlusIconsVue from '@element-plus/icons-vue'

export default {
  install(app: any) {
    // 注册项目全局组件
    const importComponents = import.meta.glob('./*/index.vue', { eager: true })
    Object.keys(importComponents).forEach((v) => {
      const componentName = v.split('/')[1]
      const componentCantance: any = importComponents[v]
      app.component(componentName, componentCantance.default || null)
    })

    // 注册elementIcon组件
    const elementIcons = Object.entries(ElementPlusIconsVue)
    for (const [key, component] of elementIcons) {
      app.component(key, component)
    }
  },
}
